<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
class OrderController extends Controller{
	
	   private $GoodsAttrModel;
	   private $TypeAttrModel;
	   public function __init(){
	   if(!isset($_SESSION['info'])) View::error('请登录！',U('User/login'));
		
		
		$this->TypeAttrModel=M('\Common\Model\sc_typeattr');
		$this->GoodsAttrModel=M('\Common\Model\sc_goods_Attr');
	}
	
	
	
	
	
	
	public function index(){
		
        if(!isset($_SESSION['cart'])){

			$data=[];
        }else{
	        $GcId=Q('get.GcId');
			$GcId=explode(",", $GcId);
			$data=[];
			foreach($GcId as $v){
				$data[]=$_SESSION['cart']['goods'][$v];
				
			}
			
			$taids=[];
			foreach($data as $k=>$v){
				$gtids=implode(",", $v['options']['options']);
	            $data[$k]['vdata']=$this->GoodsAttrModel->where("gtid IN ({$gtids})")->get();
				foreach($data[$k]['vdata'] as $kk=>$v){
					$data[$k]['vdata'][$kk]['taname']=$this->TypeAttrModel->where('taid',$data[$k]['vdata'][$kk]['sc_type_attr_taid'])->pluck('taname');
				}
			}
        }
		View::with('data',$data);
		View::make();
		
		
	}
	
	
	
	public function addressMake(){
		$addressData=Q('post.');
		$addressData['address']=implode(" ", $addressData['address']);
		echo json_encode($addressData);
	}
	
	
	
	
}


